<template>
	<view>
		<view class="header">
			<text class="iconfont icon-xiangzuojiantou
" @click="back">编辑地址</text>
		</view>
		<view class="content">
			<view class="itemleft">
				<view><text>收货人</text></view>
				<view><text>联系电话</text></view>
				<view><text>所在地区</text></view>
				<view><text>详细地址</text></view>
			</view>
			<view class="itemright">
				<input type="text" :value="name" />
				<input type="number" :value="tel" />
				<view class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<picker @change="bindPickerChange" :value="index" mode="region">
								<view class="uni-input">{{address}} <text style="text-align: end;" class="iconfont icon-youjiantou"></text></view>
							</picker>
						</view>
					</view>
				</view>
				<input type="text" :value="xiangxiaddress" />
			</view>
		</view>
		<view class="last">
			<text>设置为默认地址</text>
			<view>
				<switch checked @change="switch1Change" />
			</view>
		</view>
		<view class="btn">
			<button type="warn" @click="save">保存</button>
		</view>
	</view>
</template>

<script>
	import {reactive,toRefs} from 'vue';
	export default {
		setup(){
			let data=reactive({
				array: ['武侯区', '新都区'],
				index: 0,
				name:'',
				tel:'',
				address:'',
				xiangxiaddress:'',
				isMoren:'',
				back(){
					uni.redirectTo({
						url: '/pages/ptxqdizhi/ptxqdizhi'
					});
				},
				bindPickerChange: function(e) {
					console.log('picker发送选择改变，携带值为', e.detail.value)
					data.index = e.detail.value
					data.address=e.detail.value.join('-')
					console.log(data.index)
				},
				switch1Change(e){
					console.log('switch1 发生 change 事件，携带值为', e.detail.value)
				},
				save(){
					console.log('保存')
				}
			})
			return {...toRefs(data)}
		},
		data() {
			return {
				
			}
		},
		methods: {
			
		}
	}
</script>

<style lang="scss">
	@import url("~@/static/fonts/iconfont.css");
	.header{
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #efefef;
		display: flex;
		justify-content: space-between;
	}
	.content{
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		.itemleft{
			view{
				margin-top: 22rpx;
			}
		}
		.itemright{
			flex: 1;
			margin-left: 40rpx;
			input{
				margin-top: 20rpx;
			}
			.uni-list{
				margin-top: 20rpx;
			}
			>view{
				>view{
					display: flex;
					justify-content: space-between;
				}
			}
		}
	}
	.last{
		padding: 0rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		view{
			switch{
				transform: scale(0.7);
				margin-top: 8rpx;
			}
		}
	}
	.btn{
		text-align: center;
		margin-top: 40rpx;
		button{
			width: 370rpx;
			font-size: 16px;
		}
	}
</style>
